package com.ttxs.fileformathandling.service.inner;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.ttxs.apicommon.service.InnerApiService;
import com.ttxs.fileformathandling.common.ErrorCode;
import com.ttxs.fileformathandling.exception.BusinessException;
import com.ttxs.fileformathandling.mapper.ApiMapper;
import org.apache.commons.lang3.StringUtils;
import com.ttxs.apicommon.model.entity.Api;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @author cwt
 * @version 1.0
 */
@DubboService
public class InnerApiServiceImpl implements InnerApiService {
    @Resource
    private ApiMapper apiMapper;

    @Override
    public Api getApiInfo(String url, String method) {
        if (StringUtils.isAnyBlank(url, method)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "url method 均不能为空");
        }
        QueryWrapper<Api> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("url", url);
        queryWrapper.eq("method", method);
        return apiMapper.selectOne(queryWrapper);
    }
}
